/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DB;

/**
 *
 * @author Mariano
 */
import java.sql.DriverManager;
import com.mysql.jdbc.Connection;

public class DBConeccion {
	public static String bd = "combivoy";
	private static String login = "root";
	private static String password = "root";
	private static String url = "jdbc:mysql://localhost/"+bd;
	private static DBConeccion instance;
	private static Connection conn;
	
	public synchronized static Connection getInstance(){
		if (instance == null)
			instance = new DBConeccion();
		return conn;
	}

	public DBConeccion() {
	      try{
	         Class.forName("com.mysql.jdbc.Driver");
	         conn = (Connection) DriverManager.getConnection(url, login, password);
	         if (conn!=null){
	            System.out.println("Dabase " + bd + " Connected");
	         }
	      }catch(Exception ex){
	    	  ex.printStackTrace();
	      }
	   }

	public void closeConnection(){
	    conn = null;
	}
}
